home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / lu62 / flush.c < prev    next >
C/C++ Source or Header  |  1996-07-10  |  6KB  |  177 lines

  1.  /**********************************************************
  2.  *                                                         *
  3.  *                   F L U S H                             *
  4.  *                                                         *
  5.  *    Function  : handles the FLUSH verb processing.       *
  6.  *                                                         *
  7.  *    Input     : FLUSH verb parametrs.                    *
  8.  *    Output    : Flushe output buffers and shut down the  *
  9.  *                other activities depend on the values of *
  10.  *                "conv_state" and "error_state" variables.*
  11.  *                                                         *
  12.  *                                                         *
  13.  * CopyRight 1995. Nicholas Poljakov all rights reserved.  *
  14.  *                                                         *
  15.  **********************************************************/
  16. #include <stdio.h>
  17. #include <flush.h>
  18. #include <state1.h>
  19. #include <rcb.h>
  20. #include <tcb.h>
  21. #include <lucb.h>
  22. #include <cma.h>
  23. #include <psp.h>
  24. #include <prefix.h>
  25. #include <string.h>
  26.  
  27. extern struct psp psp_ini;
  28. int sk_r_wt(void *);
  29. int SendBlock(void *, void *);
  30. int setrc(void *, void *);
  31. int sendhsf(void *);
  32. int sendhs(void *);
  33. int sendbm(void *, void *);
  34. int sendat(void *);
  35. int rtsend(void *);
  36. unsigned long rmfmh5(void *, void *);
  37. int recwait(void *);
  38. int rcvru(void *, void *);
  39. int rcvhs(void *, void *, void *, void *);
  40. int ralloc(void *, void *);
  41. int psrm(int, void *, void *);
  42. int ps_conv(int, void *);
  43. int proterr(void *, unsigned long);
  44. int preptrcv(void *, void *);
  45. int post_rcb(void *);
  46. struct repass *postopen(void *);
  47. int phsrec(void *);
  48. int pfmh5(void *);
  49. int opndst(void *);
  50. int obtsess(void *, unsigned char);
  51. int Lrf_handler(void *);
  52. int get_sess(void *, void *);
  53. int get_attr(void *);
  54. int fsm_error(unsigned char, void *);
  55. int fsm_conv(unsigned char, unsigned char, void *);
  56. int dcp(void *);
  57. int dealloc(void *);
  58. int crtp(void *);
  59. int conv(void *);
  60. int chkparm(void *, void *);
  61. int check_end(unsigned int, void *);
  62. struct rqb *call_appl(void *);
  63. int buffmng(unsigned char, void *, void *, void *, unsigned, unsigned char, unsigned);
  64. unsigned long attltck(void *);
  65. unsigned long attacheck(void *);
  66. char *cgetmem(int, int);
  67. int sendhsf(void *);
  68. int opndst(void *);
  69. int alloc_rcb(void *, void *);
  70. int allocate(void *);
  71. int clsdst(void *);
  72.  
  73. flush (pptr)
  74. struct flush *pptr;
  75. {
  76.         struct prefix *p_prf;
  77.         struct prefix *temp;
  78.         struct rcb *p_rcb;
  79.         struct tcb *p_tcb;
  80.         struct lucb *p_lucb;
  81.         struct cma ar;
  82.         unsigned int type;
  83.         char *p;
  84.  
  85.         int  fsm_conv();
  86.         int  fsm_error();
  87.         char s;
  88.         char r;
  89.         int code;
  90.         int state;
  91.  
  92. #if OS_TYPE == 1
  93. /*********  Trace facility **********/
  94. unsigned int rtype;   /* type of record */
  95. unsigned int pnum;    /* point number */
  96. char pname[8];        /* name of module */
  97. char *drec;           /* record for dump */
  98. int  lenr;            /* record length */
  99.  
  100. rtype = INPROC;
  101. strcpy(pname, "flush");
  102. pnum = 1;
  103. drec = pptr;
  104. lenr = sizeof(struct flush);
  105. gtf(rtype, pname, pnum, drec, lenr);
  106. /***********************************/
  107. #endif
  108.  
  109.         s = 'S';
  110.         r = 'R';
  111.  
  112.         if (chkparm(pptr, &ar) == -1) {
  113.            return(0);
  114.         }
  115.         p_rcb = ar.p_rcb;
  116.         p_tcb = ar.p_tcb;
  117.  
  118.      /* Check if the RCB is in the wait queue */
  119.         if (sk_r_wt(p_rcb) == 0) {
  120.            pptr -> prim_rc = INCOMPLETE;
  121.            return (0);
  122.         }
  123.  
  124.     /*   place the verb code into the RCB  */
  125.         p_rcb -> verb_code = Flush;
  126.         p_rcb -> verb_ptr = pptr;
  127.  
  128.         pptr -> prim_rc = 0;
  129.         pptr -> sec_rc = 0;
  130.  
  131.         type = 0xffff;
  132.  
  133.         if ((p_rcb -> error_state == RCVD_ERROR)||
  134.             (p_rcb -> error_state == NO_RQS)) {
  135.             switch (p_rcb -> conv_state) {
  136.                 case SEND              :  break;
  137.                 case PREP_TO_RCV_DEFER :
  138.                 case deall_defer       :
  139.                                           if (p_rcb -> conv_state == deall_defer) {
  140.                                               type = Deallocate_flush;
  141.                                           }
  142.                                           else
  143.                                               type = PREP_TO_RCV_FLUSH;
  144.                                           break;
  145.                 default                :  pptr -> prim_rc = STATE_CHECK;
  146.                                           return 0;
  147.             }
  148.             if ((state = fsm_conv(s, Flush, p_rcb)) == -1) {
  149.                  pptr -> prim_rc = PORT_ABENDED;
  150.                  return 0;
  151.             }
  152.             if (state == 1) {
  153.                  pptr -> prim_rc = PORT_DISABLED;
  154.                  return 0;
  155.             }
  156.             if (type != 0xffff) {
  157.         buffmng('A', NULL, p, p_rcb, 0, 0, type);
  158.             }
  159.             if (p_rcb -> conv_state == deall_defer) {
  160.                 /* Purge the chain of input records */
  161.                 p_prf = p_rcb -> first_in;
  162.                 while (p_prf != NULL) {
  163.                      if ((p = p_prf -> text) != NULL) {
  164.                         free( p );
  165.                      }
  166.                      temp = p_prf;
  167.                      p_prf = p_prf -> next;
  168.                      free( temp );
  169.                 }
  170.             }
  171.             sendhsf(p_rcb);
  172.         }
  173.         else
  174.                 pptr -> prim_rc = PORT_BUSY;
  175.         return 0;
  176. }
  177.